package com.zhiyume.api.controller;

import com.zhiyume.page.PageReq;
import com.zhiyume.service.DataService;
import com.zhiyume.service.common.ConstantEnum;
import com.zhiyume.service.util.JsonUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

/**
 * Created by wang on 17/9/28.
 */
@RestController
@RequestMapping("/create/data")
@ApiIgnore
public class AddDataAction {
    @Autowired
    private DataService dataService;

    /**
     *  造模板
     */
    @RequestMapping("/addCmsTemplate")
    public String addTemplate(){
        dataService.addTemplate();
        return JsonUtil.returnSuccessInfo(ConstantEnum.CONSTANT_SUCCESS.getErrType(), ConstantEnum.CONSTANT_SUCCESS.getErrMsg());
    }


    /**
     *  造模板
     */
    @RequestMapping("/updateCoverUrl")
    public String updateCoverUrl(){
        PageReq page = new PageReq();
        dataService.updateCoverUrl(page);
        return JsonUtil.returnSuccessInfo(ConstantEnum.CONSTANT_SUCCESS.getErrType(), ConstantEnum.CONSTANT_SUCCESS.getErrMsg());
    }


    @RequestMapping("/addCmsPlaces")
    public String addCmsPlaces(){
        addTemplate();
        dataService.addTCmsPlace();
        return JsonUtil.returnSuccessInfo(ConstantEnum.CONSTANT_SUCCESS.getErrType(), ConstantEnum.CONSTANT_SUCCESS.getErrMsg());
    }


    @RequestMapping("/addAllData")
    public String addAllData(){
        addCmsPlaces();
        addDramas();
        dataService.addInformation();
        dataService.addDramaPerson();
        return JsonUtil.returnSuccessInfo(ConstantEnum.CONSTANT_SUCCESS.getErrType(), ConstantEnum.CONSTANT_SUCCESS.getErrMsg());

    }

    @RequestMapping("/addDramas")
    public String addDramas(){

        dataService.addDramas();
        return JsonUtil.returnSuccessInfo(ConstantEnum.CONSTANT_SUCCESS.getErrType(), ConstantEnum.CONSTANT_SUCCESS.getErrMsg());

    }

    @RequestMapping("/addInformations")
    public String addInformations(){
        dataService.addInformation();
        return JsonUtil.returnSuccessInfo(ConstantEnum.CONSTANT_SUCCESS.getErrType(), ConstantEnum.CONSTANT_SUCCESS.getErrMsg());
    }

    @RequestMapping("/addComment")
    public String addComment(){
        dataService.addComment();
        return JsonUtil.returnSuccessInfo(ConstantEnum.CONSTANT_SUCCESS.getErrType(), ConstantEnum.CONSTANT_SUCCESS.getErrMsg());
    }

    @RequestMapping("/addCmsHome")
    public String addCmsHome(){
        dataService.delCmsHome();
        dataService.addCmsHome();
        return JsonUtil.returnSuccessInfo(ConstantEnum.CONSTANT_SUCCESS.getErrType(), ConstantEnum.CONSTANT_SUCCESS.getErrMsg());
    }


}
